home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / lang / sofa.lha / sofa / smalleiffel / lib_show / random / example3.e < prev   
Text File  |  2000-03-25  |  2KB  |  56 lines

  1. -- This file is  free  software, which  comes  along  with  SmallEiffel. This
  2. -- software  is  distributed  in the hope that it will be useful, but WITHOUT
  3. -- ANY  WARRANTY;  without  even  the  implied warranty of MERCHANTABILITY or
  4. -- FITNESS  FOR A PARTICULAR PURPOSE. You can modify it as you want, provided
  5. -- this header is kept unaltered, and a notification of the changes is added.
  6. -- You  are  allowed  to  redistribute  it and sell it, alone or as a part of
  7. -- another product.
  8. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  9. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr
  10. --                       http://SmallEiffel.loria.fr
  11. --
  12. class EXAMPLE3
  13.  
  14. creation make
  15.  
  16. feature
  17.  
  18.    make is
  19.       local
  20.          rand: GEN_RAND;
  21.          seed, count: INTEGER;
  22.       do
  23.          if argument_count < 2 then
  24.             io.put_string("Usage: ");
  25.         io.put_string(argument(0));
  26.         io.put_string(" <seed> <count> [min_stand|std_rand]%N");
  27.         die_with_code(exit_failure_code);
  28.          end;
  29.          seed := argument(1).to_integer;
  30.          count := argument(2).to_integer;
  31.          if argument_count > 2 then
  32.             if argument(3).same_as("MIN_STAND") then
  33.                !MIN_STAND!rand.with_seed(seed);
  34.                io.put_string("Using MIN_STAND.%N");
  35.             else
  36.                !STD_RAND!rand.with_seed(seed);
  37.                io.put_string("Using STD_RAND.%N");
  38.             end;
  39.          else
  40.             !STD_RAND!rand.with_seed(seed);
  41.             io.put_string("Using default STD_RAND.%N");
  42.          end;
  43.          from
  44.          until
  45.             count = 0
  46.          loop
  47.             rand.next;
  48.             io.put_double(rand.last_double);
  49.             count := count - 1;
  50.             io.put_string("%N");
  51.          end;
  52.       end;
  53.  
  54. end -- EXAMPLE3
  55.  
  56.